import axios from 'axios'
import qs from 'qs'
function ajax(url,method,params,succBack,errBack){
    let met = 'params'
    if(method.toUpperCase() == "POST"){
        met = 'data'
        params=qs.stringify(params)
    }
    axios({
        url:url,
        method:method,
        [met]:params
    }).then(d=>{
        if(d.data.code != 0){
            errBack(d)
            return
        }
        succBack(d)
    })
}

export default ajax